import React from 'react';

//组件
export default class Index extends React.Component {
  constructor(props) {
    console.log('constructor');
    super(props);
  }

  //@babel/plugin-proposal-class-properties
  handlerClick = () => {
    alert('一起来玩 react ssr 呀。');
  };

  /** ↓服务端也会运行*/
  componentWillMount() {
    console.log('componentWillMount')
  }

  /** ↓服务端不会运行*/
  componentDidMount() {
    console.log('componentDidMount')
  }

  render() {
    console.log('render'); /** ←服务端也会运行,这是当然的,不运行怎么生成要返回的html*/
    return <h1 onClick={this.handlerClick}>click here!</h1>
  }
}
